<?php

class Operacao extends Model {
	
	public $nome = 'Operacao';
	
	public $useTabela = 'operacoes';
	
	public function operacoesNoModulo($id) {
		
		$sql = 'SELECT o.id, o.operacao_exibicao FROM modulo_operacao mo LEFT JOIN operacoes o ON (mo.operacao_id = o.id) WHERE mo.modulo_id = ? AND ';
		$sql .= 'o.status = true';
		
		$this->_stmt = $this->_instancia->prepare($sql);

		$this->_stmt->bindValue(1, $id);
		$this->_stmt->execute();
		
		$result = $this->_stmt->fetchAll();
		
		$data = array();
		
		if($result) {
			if(count($result) > 0) {
				foreach($result as $indice => $valores) {
					foreach($valores as $i => $valor) {
						if(is_string($i)) $data[$indice][$i] = $valor;
					}
				}
			}
		}
		unset($result);
		
		return $data;
	}
	
}
